<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>


  <!-- <form action="/api/home/upload"
    method="post"
    enctype="multipart/form-data"> -->
    <input type="file" name="file" class="file"/>

    <input id="submit_form" type="submit" class="btn btn-success save" value="保存"/>
  <!-- </form> -->

  <script src="/axios.js"></script>
  <script src="/jquery.js"></script>
  <script>

    $('.file').change(function() {
      console.log(this, 'this')
      let files = this.files;
      let currentTarget = files[0]
      // files文件
      console.log(files, 'files')
      let formData = new FormData();
      formData.append('file', currentTarget) // { file: 'img' }

      axios.post('/api/home/upload', formData, {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      }).then(res => {
        console.log('res...:', res)
      })
    })





    // $('.file').change(function() {
    //   console.log(this.files)
    //   let files = this.files;
    //   let uploadFile = files[0]
    //   const formData = new FormData();
    //   formData.append('file', uploadFile)

    //   axios.post('/api/home/upload', formData, {
    //     headers: {
    //        'Content-Type': 'multipart/form-data'
    //     }
    //   }).then(res => {
    //     console.log(res,'res')
    //   })
    // })




  </script>
  <!-- <form
    method="post"

    action="/api/home/upload"
  >
    <input type="file" >
   <button type="submit">submit</button>
  </form> -->

</body>
</html>
